// 筛子游戏
#include <iostream>
using namespace std;

enum class Color {
    red, white, blue
};

class Die {
private:
    int face;
    Color color;

public:
    Die() {
        face = 1;
        color = Color::white;
    }

    void RollDie() {
        face = rand() % 6 + 1;
    }

    int FaceUp() {
        return face;
    }
};

class DicePlayer {
private:
    string name;
    Die die[5];
    int total;  // 累计筛子点数

public:
    DicePlayer(string name);
    void RollTheDice();
    int ReportSum() { return total; }
    void TellWhoAndHowMuch();
    int operator!();
};

int main() {
    DicePlayer first("Richard");
    DicePlayer second("Steve");

    time_t t;
    time(&t);

    int seed = t;
    srand(seed);

    int score1, score2;
    bool go = true;
    while (go) {
        first.RollTheDice();
        second.RollTheDice();

        score1 = first.ReportSum();
        score2 = second.ReportSum();

        first.TellWhoAndHowMuch();
        second.TellWhoAndHowMuch();

        if (!first || !second) {
            cout << "有人得了50分\n";
            if (!first) {
                first.TellWhoAndHowMuch();
            }
            else {
                second.TellWhoAndHowMuch();
            }
            cout << "赢得 $1,000,000 大奖!\n";
            go = false;
        }
        else if (score1 >= 100 && score2 >= 100) {
            cout << "两人都得了100分,平局\n";
            go = false;
        }
        else if (score1 >= 100 || score2 >= 100) {
            cout << "有人得了100分!\n";
            if (score1 >= 100) {
                first.TellWhoAndHowMuch();
            }
            else {
                second.TellWhoAndHowMuch();
            }
            cout << "他胜了\n";
            go = false;
        }
        cout << "游戏结束\n";
    }
}

DicePlayer::DicePlayer(string name) {
    this->name = name;
    total = 0;
}

void DicePlayer::RollTheDice() {
    for (int i = 0; i < 5; i++) {
        die[i].RollDie();
        total += die[i].FaceUp();
    }
}

void DicePlayer::TellWhoAndHowMuch() {
    cout << name << " 得了 " << total << " 分\n";
}

int DicePlayer::operator!() {
    return total == 50 ? 1 : 0;
}